//高精度加减法

#include <stdio.h>
#include <string.h>

void split( char *a , char *b , char *c , char *d );
void chartoint( char *a , int *b );
int max( int comparator1 , int comparator2 );
void sum( int *addend1 , int *addend2 , int *result);
void subtract( int *subtractor1 , int *subtractor2 , int *result );
void reverse ( int *initial , int *result );
int size( int *a );

int main()
{
	char front[100]={'\0'},back[100]={'\0'},all[100]={'\0'},d[1]={'\0'};
	int process1[100]={0},process2[100]={0},result[100]={0},n,a,flag=0,length1,length2;
	scanf("%d",&n);
	a=getchar();
	for ( int i=1 ; i<=n ; i++)
	{
		gets(all);
		split ( front , back , all , d );
		length1=strlen( front );
		length2=strlen( back );
		if( length1 > length2 || ( strcmp(front,back) > 0 && length1==length2 ) )
		{
			chartoint ( front , process1 );
			chartoint ( back , process2 );
		}
		else
		{
			flag=1;
			chartoint ( back , process1);
			chartoint ( front , process2);
		}
		if ( d[0]=='+')
		{
			sum( process1 , process2 , result );
		}
		else if( d[0]=='-')
		{
			subtract( process1 , process2 , result );
			if ( flag==1 && result[0]!=0 )
			{
				printf("%c",d[0]);
			}
		}
		if ( result[0]==0 )
		{
			printf("0");
		}
		else
		{
			for ( int k=0 ; result[k]!=0 ; k++ )
			{
				printf("%d",result[k]);
			}		
		}
		printf("\n");
		memset( result , 0 , sizeof(result) );
		memset( process1 , 0 , sizeof(process1) );
		memset( process2 , 0 , sizeof(process2) );
		memset( front , 0 , sizeof(front) );
		memset( back , 0 ,sizeof(back) );
		memset( all , 0 , sizeof(all) );
	}
	return 0;
	
}

void split( char *a , char *b , char *c , char *d )	//a为前面的数字 b为后面的数字 c为全式子 d为符号
{
	int len,i=0;
	len = strlen(c);
	for ( i=0 ; c[i] != 43 && c[i] != 45 ; i++)
	{
		a[i] = c[i];
	}
	d[0] = c[i];
	for ( int j=0 ; i+j+1<=len-1 ; j++ )
	{
		b[j] = c[i+j+1];
	}
}

void chartoint( char *a , int *b )	//将char型字符转换为int型数,同时颠倒顺序
{
	int length;
	length = strlen(a);
	for ( int i=0 ; i <= length-1 ; i++ )
	{
		b[i] = a[length-i-1] - 48;
	}
}

int max( int comparator1 , int comparator2 )	//得到最大数
{
	if ( comparator1 >= comparator2 )
	{
		return comparator1;
	}
	else
	{
		return comparator2;
	}
}

void sum( int *addend1 , int *addend2 , int *result)	//求出加和并且反向给到结果之中
{
	int length1=0,length2=0,length=0;
	length1 = size( addend1 );
	length2 = size( addend2 );
	length=max( length1 , length2 );
	for ( int i=0 ; i<=length-1 ; i++ )
	{
		addend1[i]=addend1[i]+addend2[i];
		if ( addend1[i] >= 10 )
		{
			addend1[i] = addend1[i] - 10;
			addend1[i+1] = addend1[i+1] + 1;
		}
	}
	reverse( addend1 , result );
}

void subtract( int *subtractor1 , int *subtractor2 , int *result )
{
	int length1=0,length2=0,length=0;
	length1 = size( subtractor1 );
	length2 = size( subtractor2 );
	length=max( length1 , length2 );
	for ( int i=0 ; i<=length-1 ; i++ )
	{
		subtractor1[i]=subtractor1[i]-subtractor2[i];
		if ( subtractor1[i] < 0)
		{
			subtractor1[i] += 10;
			subtractor1[i+1] -= 1;
		}
	}
	reverse( subtractor1 , result );
}

void reverse ( int *initial , int *result )	//将结果反向
{
	int median,length;
	length = size( initial );
	for ( int j=0 ; j<=length-1 ; j++ )
	{
		result[j] = initial[length-j-1];
	}
}

int size( int *a )
{
	int i=0;
	while( a[i]!=0 )
	{
		i++;
	}
	return i;
}


